import request from '@/utils/request'

const basePath = '/jpower-system'

/**
 * @description: 数据列表
 * @param {*} params
 * @return {*}
 */
export function getList(params) {
  return request({
    url: basePath + '/core/dataScope/listPage',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 通过菜单 ID 查询
 * @param {*} params
 * @return {*}
 */
export function getListByMenu(params) {
  return request({
    url: basePath + `/core/dataScope/listByMenuId`,
    method: 'get',
    params
  })
}

/**
 * @description: 创建
 * @param {*} params
 * @return {*}
 */
export function addScope(params) {
  return request({
    url: basePath + `/core/dataScope/add`,
    method: 'post',
    params
  })
}

/**
 * @description: 通过角色ID查询所有的数据权限
 * @param {*} roleIds
 * @return {*}
 */
export function getListByRole(roleIds) {
  return request({
    url: basePath + `/core/dataScope/listIdByRoleId`,
    method: 'get',
    params: { roleIds }
  })
}

export function deleteRole(roleIds) {
  return request({
    url: basePath + `/core/dataScope/delete`,
    method: 'delete',
    params: { id: roleIds }
  })
}

export function editRole(params) {
  return request({
    url: basePath + `/core/dataScope/update`,
    method: 'put',
    params
  })
}

export function roleDataScope(params) {
  return request({
    url: basePath + '/core/dataScope/roleDataScope',
    method: 'post',
    params
  })
}
